#include "p_error.h"

#include "p_strutils.h"

p_error_struct error_struct_create(const std::string &msg,
                                   const std::string &file_name,
                                   const p_unsigned_int &line,
                                   const p_unsigned_int &col)
{
   p_error_struct result;
   result.msg = msg;
   result.file_name = file_name;
   result.line = line;
   result.col = col;
   return result;
}

p_error_struct error_struct_create(const std::string &msg)
{
   return error_struct_create(msg, "", 0, 0);
}

std::string error_struct_to_string(const p_error_struct &error_struct)
{
   return "At line " + to_string(error_struct.line) + " ("
            + to_string(error_struct.col) + "):\n\t" + error_struct.msg;
}
